package net.libra.scrollui
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;

	/**
	 * 竖直布局
	 * @author 姜波
	 * @createTime 2010-12-18
	 * @version 1.0
	 * */
	public class VLayout
	{
		public static function layout(container:DisplayObjectContainer,verticalGap:Number):void
		{
			var children:Array = getChildren(container);
			var top:Number = 0;
			for(var i:int = 0; i < children.length; i++)
			{
				var child:DisplayObject = children[i] as DisplayObject;
				child.y = top;
				top += child.height + verticalGap;
			}
		}
		public static function getChildren(container:DisplayObjectContainer):Array
		{
			var result:Array = new Array();
			for(var i:int = 0; i < container.numChildren; i++)
			{
				result.push(container.getChildAt(i));
			}
			return result;
		}
		public static function getContentHeight(container:DisplayObjectContainer,verticalGap:Number):Number
		{
			var children:Array = getChildren(container);
			var top:Number = 0;
			for(var i:int = 0; i < children.length; i++)
			{
				var child:DisplayObject = children[i] as DisplayObject;
				top += child.height + verticalGap;
			}
			return top;
		}
	}
}